package com.woniuxy.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.daos.ServiceDao;
import com.woniuxy.entitys.Company;
import com.woniuxy.entitys.Service;
import com.woniuxy.services.ServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;
import java.util.Map;

@org.springframework.stereotype.Service
@Transactional
public class ServiceServiceImpl implements ServiceService {

    @Autowired
    private ServiceDao serviceDao;
    @Override
    public PageInfo<Service> selectAllService(Integer currentPage, Integer pageSize, String key, String value) {
        PageHelper.startPage(currentPage,pageSize);
        List list = serviceDao.selectAllService(key, value);
        PageInfo<Service> pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public PageInfo<Service> selectAll(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        List list = serviceDao.selectAll();
        PageInfo<Service> pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public int saveService(Service service) {
        return serviceDao.saveService(service);
    }

    @Override
    public List<Company> selectByComName(String name) {
        return serviceDao.selectByComName(name);
    }

    @Override
    public Service selectByPrimaryKey(Integer svr_id) {
        return serviceDao.selectByPrimaryKey(svr_id);
    }

    @Override
    public int upddue(Integer id) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Service service) {
        return serviceDao.updateByPrimaryKey(service);
    }


    @Override
    public int insertSelective(Service service) {
        return serviceDao.insertSelective(service);
    }

    //根据年份和客户id分组查询
    @Override
    public List<Map<String, Object>> getServeCount(String year, Integer com_id) {
        return serviceDao.getServeCount(year,com_id);
    }

}
